const YYYY_MM_DD = dateformat"yyyy-mm-dd"
const HH_MM_SS = dateformat"HH:MM:SS"
const HH_MM_SSsss = dateformat"HH:MM:SS.sss"

parse_yyyy_mm_dd(s::String) = Base.Dates.Date(Base.Dates.parse_components(s, YYYY_MM_DD)...)
parse_hh_mm_ss(s::String) = Base.Dates.Time(Base.Dates.parse_components(s, HH_MM_SS)...)
parse_hh_mm_sss(s::String) = Base.Dates.Time(Base.Dates.parse_components(s, HH_MM_SSsss)...)
function parse_hh_mm_ssss(str::String)
    str = strip(str)
    if contains(str, ".")
        str, str_subseconds = split(str, '.')
        str_subseconds = string(str_subseconds, ZEROCHARS[1:(9-length(str_subseconds))])
    else
        subseconds_str = ""
    end
    tm = parse_hh_mm_ss(str)
    subsecs = parse(Int, subseconds_str)
    tm = tm + Nanoseconds(subsecs)
    return tm
end

parse_yyyy_mm_dd(s::SubString) = Base.Dates.Date(Base.Dates.parse_components(s, YYYY_MM_DD)...)
parse_hh_mm_ss(s::SubString) = Base.Dates.Time(Base.Dates.parse_components(s, HH_MM_SS)...)
parse_hh_mm_sss(s::SubString) = Base.Dates.Time(Base.Dates.parse_components(s, HH_MM_SSsss)...)
parse_hh_mm_ssss(s::SubString) = parse_hh_mm_ssss(String(s))
